package com.github.zw201913.simplehttp.example.controller;

import com.github.zw201913.simplehttp.example.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestController {

    @Autowired private TestService testService;

    @GetMapping("/list")
    public String list() {
        return testService.list();
    }

    @GetMapping("/find/{id}")
    public String find(@PathVariable("id") Integer id) {
        return testService.find(id);
    }

    @GetMapping("/add")
    public String add() {
        return testService.add();
    }

    @GetMapping("/douyin")
    public String testDouyin() {
        String accessToken = "accessToken_example"; // String |
        String openId = "openId_example"; // String |
        Map<String, String> map = new HashMap<>();
        map.put(accessToken, "token");
        map.put(openId, "openId");
        return testService.userInfoApi("https://open.douyin.com/oauth/userinfo/", map);
    }
}
